package cn.slt.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.slt.domian.Category;
import cn.slt.mapper.CategoryMapper;
import cn.slt.service.CategoryService;
@Service
@Transactional
public class CategoryServiceImpl implements CategoryService{
	@Autowired
	private CategoryMapper mapper;
	public List<Category> queryCategoryList(String firCode,String secCode) {
		Map<String, String> map=new HashMap<String, String>();
		map.put("firCode", firCode);
		map.put("secCode", secCode);
		//System.out.println(map.get("firCode"));
		return mapper.queryCategoryList(map);
	}
	
	public List<Category> getfirstlev() {
		// TODO Auto-generated method stub
		return mapper.getfirstlev();
	}
	
	public List<Category> getsecondlev(String firstcode) {
		// TODO Auto-generated method stub
		return mapper.getsecondlev(firstcode);
	}
	public List<Category> queryZtree() {
		return mapper.queryZtree();
	}

	@Override
	public Category getone(Category category) {
		// TODO Auto-generated method stub
		return mapper.getone(category);
	}

	public List<Category> queryFirstLevel() {
		return mapper.queryFirstLevel();
	}

	public List<Category> querySecondLevel(String firCode) {
		return mapper.querySecondLevel(firCode);
	}

	public boolean isExistFirst(String firName) {
		List<Category> list = mapper.isExistFirst(firName);
		boolean mark; 
		if(list.isEmpty()){//如果为空,没找到
			mark = false;
		}
		else mark = true;
		return mark;
	}
	
	public boolean isExistSecond(String firName, String secName) {
		Map<String, String> map=new HashMap<String, String>();
		map.put("firName", firName);
		map.put("secName", secName);
		List<Category> list = mapper.isExistSecond(map);
		boolean mark; 
		if(list.isEmpty()){//如果为空,没找到
			mark = false;
		}
		else mark = true;
		return mark;
	}
	
	public boolean isExistThird(String firName, String secName, String thiName) {
		Map<String, String> map=new HashMap<String, String>();
		map.put("firName", firName);
		map.put("secName", secName);
		map.put("thiName", thiName);
		List<Category> list = mapper.isExistThird(map);
		boolean mark; 
		if(list.isEmpty()){//如果为空
			mark = false;
		}
		else mark = true;
		return mark;
	}
	
	
	public String queryMaxfirCode() {
		return mapper.queryMaxfirCode();
	}
	
	public String queryMaxSecCode(String firCode) {
		return mapper.queryMaxSecCode(firCode);
	}
	
	public String queryMaxThiCode(String firCode, String secCode) {
		Map<String, String> map = new HashMap<String, String>();
		map.put("firCode", firCode);
		map.put("secCode", secCode);
		return mapper.queryMaxThiCode(map);
	}

	public boolean addBatch(List<Category> li) {
		return mapper.addBatch(li);
	}

	public boolean delFirst(String firCode) {
		return mapper.delFirst(firCode);
	}

	public boolean delSecond(String firCode, String secCode) {
		Map<String, String> map = new HashMap<String, String>();
		map.put("firCode", firCode);
		map.put("secCode", secCode);
		return mapper.delSecond(map);
	}

	public boolean delThird(String firCode, String secCode, String thiCode) {
		Map<String, String> map = new HashMap<String, String>();
		map.put("firCode", firCode);
		map.put("secCode", secCode);
		map.put("thiCode", thiCode);
		return mapper.delThird(map);
	}
	
}
